home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 2 / Atari Mega Archive CD - Volume 2.iso / 8bit / cislib_a / center.pas < prev    next >
Pascal/Delphi Source File  |  1995-04-22  |  978b  |  28 lines

  1. PROCEDURE Center(Line : String;  VAR xpos : Integer;  ypos : Integer);
  2. (*
  3.   by Erik C. Warren, 14 January, 1987
  4.   for UPDATE...KYAN, Jan./Feb. '87
  5.   Prior to calling this routine, you must have declared:
  6.         CONST MaxString = n; (n is a number of your choice)
  7.          TYPE String = ARRAY[1..MaxString] OF Char;
  8.  
  9.   You must also have included the files "POSITION.I" and "LENGTH.I"
  10.   from the K.P. disk, side two.
  11.  
  12.   xpos must be passed by reference as a VARiable, not as a value
  13.      parameter; it will be changed to reflect the horizontal position
  14.      at which the string is written to.
  15.  
  16.   ypos is the vertical position you want the string to be written at.
  17. *)
  18.  
  19. CONST MaxCols = 40; (* or 80 if your system has the capability *)
  20.  
  21. BEGIN
  22. (* Calculate new x *)
  23.   xpos := MaxCols DIV 2 - 1 - (Length(Line) DIV 2);
  24.   IF xpos < 0 THEN xpos := 0; (* range check *)
  25.   Position(xpos,ypos); (* Goto X,Y cursor coordinates *)
  26.   Write(Line) (* Write string, no CR *)
  27. END; (* Center *)
  28.